from dataclasses import dataclass

from src.application.category.dto import CategoryDTO
from src.application.category.uow import CategoryUoW


@dataclass(frozen=True)
class GetCategoryByName:
    category_name: str


class GetCategoryByNameHandler:
    """
    Получение категории по имени
    """

    def __init__(self, *, uow: CategoryUoW) -> None:
        self._uow = uow

    async def __call__(self, command: GetCategoryByName) -> CategoryDTO:
        return await self._uow.category_reader.get_category_by_name(command.category_name)
